# from db.common import cli
# import datetime
#
#
# def write_report_to_projectGroup(author,project,title,article):
#     # mysql python 的日期传递方式：python中传入str类型数据，需要用%Y-%m-%d格式
#     # mysql如果存储date类型 传给python的为date_time.date格式数据，可通过str情之类型转化成字符串
#     # mysql如果存储为varchar类型，返回给python str类型。
#
#     # 1.得到当前时间戳
#     time = datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
#
#     # 2.根据项目组名称得到接收方用户
#     sql_users = "select users,project_name from project where project_id='%s' "%tuple([project])
#     res = cli.fetchall(sql_users)[0]
#     users = res['users']
#     project = res['project_name']
#     # 3.根据用户个数，填充初始未读日报字段。
#     if_read_len  = len(users.split(';'))
#     if_read_str = ''
#     for i in range(if_read_len):
#         if_read_str+='0'
#         if i != if_read_len-1:
#             if_read_str +=';'
#
#     # 4.将传入的用户具体日报数据做规范化处理，存到数据库中
#     today_str, unfini_str, tomorrow_str=uniform_report_data(article)
#
#     # 5.将数据写入数据库。
#     sql_write ="insert into logs (date_time,author,receiver,title,project,today_work,remain_todo,tomorrow_work,if_read)" \
#                "values ('%s','%s','%s','%s','%s','%s','%s','%s','%s')"%tuple([time,author,users,title,project,today_str, unfini_str, tomorrow_str,if_read_str])
#     print(sql_write)
#     cli.execute(sql_write)
#
# def write_report_to_person(author, receiver, title, article):
#     # 1.得到当前时间戳
#     time = datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
#     # 2.得到当前作者所在的部门
#     Blur_author = '%' + author + '%'
#     sql_department = "select department from department where users like '%s'" % Blur_author
#     department = cli.fetchall(sql_department)[0]['department']
#     # 3.将传入的用户具体日报数据做规范化处理，存到数据库中
#     today_str, unfini_str, tomorrow_str = uniform_report_data(article)
#     # 4.得到需要发送的对象的用户名
#     sql_user = "select login_name from user where user_id ='%s'"%receiver
#     user = cli.fetchall(sql_user)[0]['login_name']
#     # 5.将数据写入数据库。
#     sql_write = "insert into logs (date_time,author,receiver,title,department,today_work,remain_todo,tomorrow_work,if_read)" \
#                 "values ('%s','%s','%s','%s','%s','%s','%s','%s','%s')" % tuple(
#         [time, author, user, title, department, today_str, unfini_str, tomorrow_str,'0'])
#     print(sql_write)
#     cli.execute(sql_write)
#
#
#
# def uniform_report_data(article):
#     today_str = ''
#     unfini_str = ''
#     tomorrow_str = ''
#     for i in article['todaylist']:
#         today_str +=i
#         if i != article['todaylist'][len(article['todaylist'])-1]:
#             today_str +='/*/*/'
#     for i in article['unfinilist']:
#         unfini_str +=i
#         if i != article['unfinilist'][len(article['unfinilist'])-1]:
#             unfini_str += '/*/*/'
#     for i in article['tomolist']:
#         tomorrow_str +=i
#         if i != article['tomolist'][len(article['tomolist'])-1]:
#             tomorrow_str +='/*/*/'
#     return today_str,unfini_str,tomorrow_str